package zlatan_demo18_function

/**
 * @author Zlatan
 * @date 2021/12/8 14:57
 * @version 1.0
 */
object LambdaTest {
  def main(args: Array[String]): Unit = {
    /*
    练习1
     */
    val fun = (a: Int, b: String, c: Char) => {
      if (a == 0 && b == "" && c == '0') false else true
    }
    println(fun(0, "", '0'))
    println(fun(2, "", '0'))
    println(fun(3, "", '0'))

    println("=======================")

    /*
    练习2
     */
    def func(a: Int): String => (Char => Boolean) = {
      def f1(b: String): Char => Boolean = {
        def f2(c: Char): Boolean = {
          if (a == 0 && b == "" && c == '0') false else true
        }
        f2
      }
      f1
    }
    println(func(0)("")('0'))

    println("=======================")

    //匿名函数简写
    def func1(a: Int): String => (Char => Boolean) = {
      b=>c=>if (a == 0 && b == "" && c == '0') false else true
        }
    println(func1(0)("")('0'))
    println(func1(2)("")('0'))
    println(func1(3)("")('0'))

    println("=======================")
    //柯里化
    def func2(a:Int)(b:String)(c:Char):Boolean={
      if (a == 0 && b == "" && c == '0') false else true
   }
    println(func2(0)("")('0'))
    println(func2(2)("")('0'))
    println(func2(3)("")('0'))

  }

}
